$(function() {
	var end = false;
	var page = 0;
	var loading = false; // 状态标记
	$('#div1').css('height', $(window).height());
	$('#div1').pullToRefresh();
	$('#div1').on("pull-to-refresh", function() {
		page = 0;
		end = false;
		loadData(true);
		$('#div1').pullToRefreshDone();
	});
	$('#div1').infinite().on("infinite", function() {
		loadData(false);
	});
	$('#div1').trigger('pull-to-refresh');

	function loadData(type) {
		if (loading)
			return false;
		if (end) {
			return false;
		}
		loading = true;
		$("#loading-div").show();
		$.ajax({
			url : appPath + '/article/list/' + $("#articleClassId").val() + '/' + page + '.html',
			dataType : 'html',
			data : {
			},
			success : function(result) {
				var over = $("#over").val();
				if (over) {
					end = true;
				} else {
					page = page + 1;
					if (type) {
						$(".weui_panel_bd").html(result);
					} else {
						$(".weui_panel_bd").append(result);
					}
				}
				$("#loading-div").hide();
				loading = false;
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$.hideLoading();
				$("#loading-div").hide();
				$.alert("系统异常，请重试");
			}
		});
	}
})
function detail(id) {
	window.location.href = appPath + "/article/detail/" + id + ".html";
}